package com.lingyun.mqttserver.controller;

import com.lingyun.mqttserver.dao.pojo.MqttSaveVo;
import com.lingyun.mqttserver.dao.pojo.MqttScreenVariableMapping;
import com.lingyun.mqttserver.dao.pojo.MqttScreenVariableMappingVariable;
import com.lingyun.mqttserver.service.ManageDataService;
import com.lingyun.mqttserver.vo.MqttBatchSaveVo;
import com.lingyun.mqttserver.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("mqtt-screen")
public class MqttScreenMappingController {

    @Autowired
    private ManageDataService manageDataService;

    @GetMapping("getMqttScreens")
    private Result getMqttScreens(@RequestParam(required = false) Integer projectId){
        return manageDataService.getMqttScreens(projectId);
    }

    @GetMapping("getMqttMappings")
    private Result getMqttMappings(@RequestParam Integer screenId, @RequestParam Integer groupId){
        return manageDataService.getMqttMappings(screenId, groupId);
    }

    /**
     * 映射列表
     * @param screenId
     * @param groupId
     * @param projectId
     * @return
     */
    @GetMapping("mappingList")
    private Result mappingList(@RequestParam Integer screenId, @RequestParam Integer groupId, @RequestParam(required = false) Integer projectId){
        return manageDataService.mappingList(screenId, groupId, projectId);
    }

    @PostMapping("mappingSave")
    private Result mappingSave(@RequestBody MqttSaveVo variable){
        System.out.println("保存接口触发" + variable);
        return manageDataService.mappingSave(variable);
    }

    @PostMapping("mappingSaveBatch")
    public Result mappingSaveBatch(@RequestBody MqttBatchSaveVo batchVo) {
        return manageDataService.mappingSaveBatch(batchVo);
    }

    @DeleteMapping("mappingDelete")
    public Result mappingDelete(@RequestParam Integer id){
        return manageDataService.mappingDelete(id);
    }

}
